<%@ page language="java" contentType="text/html; charset=UTF-8" pageEncoding="UTF-8"%>
<%@ taglib uri="/WEB-INF/tld/c.tld" prefix="c" %> 
<%@ taglib uri="/WEB-INF/tld/ui.tld" prefix="ui" %> 
<%String path = request.getContextPath() ;%>
<!DOCTYPE html>
<html lang="zh-CN">
<head>
<jsp:include page="../../import.jsp" flush="true" />
<jsp:include page="../../ass/assParking/assParkCommon.jsp" flush="true" />
<script type="text/javascript" src="<%=path %>/resource/lib/plugins/ajaxfileupload.js"></script>
</head>
<body class="iframeBody">
<div class="Wrapper">
<div>
<div id="pageInTab" class="pageInTab">
	<!-- 页签1
	<div tabid="tabA" title="档案管理" lselected="true">-->
		<div class="searchArea">
			<!-- 搜索表单开始 -->
			<form id="searchBar">
				<div class="fieldset1 clearFix">
					<div class="FXBR">
						
						<div class="fieldBox">
							<div class="label">合同号</div>
							<div class="field">
								<input type="text" id="contractNo" name="contractNo" class="ui-textbox" ligerui="width: 160" value="">
							</div>
						</div>
						<div class="fieldBox">
							<div class="label">支付表号</div>
							<div class="field">
								<input type="text" id="paylistCode" name="paylistCode" class="ui-textbox" ligerui="width: 160" value="">
							</div>
						</div>
						<div class="fieldBox">
							<div class="label">承租人名称</div>
							<div class="field">
								<input type="text" id="cstNm" name="cstNm" class="ui-textbox" ligerui="width: 160" value="">
							</div>
						</div>
						<div class="fieldBox">
							<div class="label">归档地点</div>
							<div class="field">
								<select id="flowPlace"  name="flowPlace"  ligerui="width: 160">
									<option value="">请选择</option>
									<c:forEach items="${flowPlaceList}" var="item">
										<option value="${item.key}">${item.value}</option>
									</c:forEach>
								</select>
							</div>
						</div>
						<div class="fieldBox">
							<div class="label">所属机构</div>
							<div class="field">
								<select id="buOrgCd"  name="buOrgCd"  ligerui="width: 160">
									<option value="">请选择</option>
									<c:forEach items="${buOrgList}" var="item">
										<option value="${item.key}">${item.value}</option>
									</c:forEach>
								</select>
							</div>
						</div>
						
						<div class="fieldBox">
							<div class="label">转仓状态</div>
							<div class="field">
								<select id="status"  name="status"  ligerui="width: 160">
									<option value="">请选择</option>
									<c:forEach items="${statusList}" var="item">
										<option value="${item.key}">${item.value}</option>
									</c:forEach>
								</select>
							</div>
						</div>
						<div class="fieldBox">
							<div class="label">支付表状态</div>
							<div class="field">
								<select id="payTStatus"  name="payTStatus"  ligerui="width: 160">
									<option value="">请选择</option>
									<c:forEach items="${payTStatusNmList}" var="item">
										<option value="${item.key}">${item.value}</option>
									</c:forEach>
								</select>
							</div>
						</div>
						
						
	               	    
					</div>
					
					
					<div class="clearFix"></div>
					
					<!-- 表单按钮 -->
					<div class="btnsBox formBtns notRight">
						<span id="searchBtn" class="sq-button-round">查询</span>
						<span id="clearBtn" class="sq-button-round">清空</span>
		            </div>
		           
				</div>
			</form>
			<!-- 搜索表单结束 -->
		</div>
		<!-- 列表显示块 -->
		<div id="ligergrid1" class="sq-grid"></div>
	</div>
	
</div>
</div>
</div>
<script type="text/javascript">
	var pageInApp={
		flag:false //tab页验证关闭
	};//to下一级子窗口 接口
	var pageInTab=null;//页签
	var loadedTabs=[];//页签
	var grid = null;
	$(function () {
	    initForm();//初始化表单
	    initGrid();//注意初始化要在initForm之后,因为在初始化grid的时候需要form参数
	    //initTab();//初始化页签
	    searchBtnEvent();//查询按钮事件
	    clearBtnEvent();//清空按钮事件
	});
	
	//初始化表单
	function initForm(){
		$("#searchBar").ligerForm();
	}
	
	//查询参数
	function getSearchParams(){
		var form = new liger.get("searchBar");
		var data = form.getData();
		return data;
	}
	
	//初始化列表
	function initGrid(){
		$("#ligergrid1").ligerGrid({
			url:'<%=path%>/archive/arcSwitchMain/initList.do',
			method:'get',
			parms:getSearchParams(),
			columns:[
				{ display: '承租人名称', name: 'cstNm', width: 120 , enabledSort:true},
				{ display: '合同号', name: 'contractNo', minWidth: 180 , align:'center', enabledSort:true},
				{ display: '支付表号', name: 'paylistCode', minWidth: 180 , align:'center', enabledSort:true},
			   	 
				{ display: '所属机构', name: 'buOrgCdNm', width: 120 , enabledSort:true},
				{ display: '省公司 ', name: 'cstMgrOrgCdPr', width: 150 , enabledSort:true},
				{ display: '分公司 ', name: 'cstMgrOrgCdCy', width: 150 , enabledSort:true},
				
				{ display: '支付表状态', name: 'payTStatusNm', minWidth: 100 ,  enabledSort:false},
				{ display: '诉讼状态', name: 'suStatusNm', minWidth: 100 ,  enabledSort:false},
				
				{ display: '属地合同管理员', name: 'cstPlace', minWidth: 200 , enabledSort:false},
				{ display: '转仓标识', name: 'flowPlace', minWidth: 100 , enabledSort:false,
					render:function (rowdata, rowindex, value){
						var h="";
						   if(rowdata.flowPlace=='ZB' ){
							    h='属地转总部';
							}else if(rowdata.flowPlace!=null&&rowdata.flowPlace!=''){
								h='总部转属地';
							}
								
		                			                
						return h;
					}
				},
				{ display: '转仓状态', name: 'statusNm', minWidth: 80 ,  enabledSort:false},
				{
					display:'操作',
					isSort:false,
					width:220,
					align:'left',
					render:function (rowdata, rowindex, value){
						var h="";
						    if((rowdata.status == "0" || rowdata.status == "2")//转仓状态
								   &&(rowdata.suStatus == "0000" || rowdata.suStatus == "0003"||rowdata.suStatus == "0006")//诉讼状态
								   &&(rowdata.cstPlace != null && rowdata.cstPlace !='' //属地合同管理员
									&&rowdata.mdfUsrId!=null	   )//归档数据
								   ){
							    h+='<a class="sq-button-hasicon" href="javascript:warrantApply(';
				            	h+="'"+rowdata.contractNo+"'";
				                h+=")\"><i class='sqBtnIco_4'></i>转仓申请</a>";
							}else{
								h+="转仓申请";
							}
		                	
		                	h+='<a class="sq-button-hasicon" href="javascript:viewFlow(';
		                	h+="'"+rowdata.paylistCode+"'";
			                h+=")\"><i class='sqBtnIco_4'></i>流程信息</a>";
		                
						return h;
					}
				},
			],
			pageSize:10,
			root:'rows',
			record:'total',
			hideLoadButton:false,
			width:'100%',
			height:'100%',
			heightDiff:-2,
			isScroll: true,
			checkbox:false,//列表是否有选择框
			rownumbers:true,//列表是否有行号
			frozen: false,
			//选择行事件
			onSelectRow: function(rowdata, rowid, rowobj){
				//设置当前选择的拖车主表ID和明细表ID值
				//$("#tcDetailId").val(rowdata.id);
				//$("#tcMasterId").val(rowdata.masterId);
			},
			//取消选择行事件
			onUnSelectRow : function(rowdata, rowid, rowobj){
				//清空当前选择的拖车主表ID和明细表ID值
				//$("#tcDetailId").val('');
				//$("#tcMasterId").val('');
			},
			detail: {
                height: 'auto',
                onShowDetail: showDetail_grid
            }
		});
		grid = liger.get("ligergrid1");
		grid.setHeight(100);
		//grid.options.isSingleCheck = true;//列表是否为单选
	}
	//发起申请
	function warrantApply(contractNo){
		//回调刷新列表
		var param = '<%=path%>/archive/arcSwitchMain/toFlow.do?contractNo=' + contractNo;
		
		Add_navTab('SwitchManage'+contractNo,'转仓申请',param, function () {
			grid.reload();
		});
	}
	
	//查看详情
	function viewDetail(paySchId,contractNo){
		//回调刷新列表
		var param = '<%=path%>/archive/arcMgrMain/viewDetail.do?paySchId=' + paySchId+'&contractNo='+contractNo ;
		
		Add_navTab('warrantApply'+paySchId,'查看详情',param, function () {
			//grid.reload();
		});
	}
	//查看流程
	function viewFlow(paylistCode){
		//回调刷新列表
		var param = '<%=path%>/archive/arcSwitchMain/toViewFlow.do?paylistCode=' + paylistCode ;
		
		Add_navTab('toSwitchViewFlow'+paylistCode,'查看流程',param, function () {
			//grid.reload();
		});
	}
	
	
	//查询按钮事件
	function searchBtnEvent(){
		$("#searchBtn").click(function(event) {
			var form = new liger.get("searchBar");
			var data = form.getData();
			//alert(JSON.stringify(data));
			for (name in data){
				grid.setParm(name,data[name]);
			};
			grid.reload();
		});
	}

	//清空按钮事件
	function clearBtnEvent(){
		$("#clearBtn").click(function(event) {			
			$("#resetBtn").click();  //重置 input-text
			var form = liger.get("searchBar");
			form.setData({  //重置select等特殊表单
				"cstNm":"",
				"contractNo":"",
				"paylistCode":"",
				"flowPlace":"",
				"storageStatus":"",
				"buOrgCd":"",
				"payTStatus":"",
				"status":"",
								
			});
			//searchOrgTree2.setValue('');			
			//liger.get("cstMgrOrgCd").clear();//清空树
			//searchOrgTree2.clear();//清空树
			//alert($("#cstMgrOrgCd").val());
			//alert($("#cstMgrOrgCd").attr("placeholder"));
		});
	}
	//加号展开列表
	 function showDetail_grid(row, detailPanel, callback) {
		 
	     var gridBox = document.createElement('div');
	     $(gridBox).css('margin', 10);
	     $(detailPanel).css({
	         'padding': 1,
	         'box-sizing': 'border-box'
	     }).append(gridBox);
	     detailGrid = $(gridBox).ligerGrid({
	            url: '<%=path%>/archive/arcSwitchMain/initArchiveList.do?paylistCode='+row.paylistCode,
	         method: 'get',
	         columns: [
	             {display: '权证资料', name: 'fileName', width: 230, align: 'left'},
	             {display: '借出状态', name: 'borrowStatusNm', width: 90, align: 'left'},
	             {display: '归档地点（起）', name: 'placeBeginNm', width: 150, align: 'left'},
	             {display: '归档地点（终）', name: 'placeEndNm', width: 150, align: 'left'}
	         ],
	         root: 'rows',
	         hideLoadButton: true,
	         width: '100%',
	         height: 'auto',
	         isScroll: false,
	         rownumbers: true,  //显示序号
	         checkbox: false,
	         allowUnSelectRow: true,
	         alternatingRow: true,
	         onAfterShowData: callback,
	         frozen: false,
	         usePager: false
	     });
	 }
</script>
</body>
</html>